<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
  defined('_JEXEC') or die('Retricted Access');
  
  JHTML::_('behavior.tooltip');
?>

<script type="text/javascript" language="javascript">
<!--
function submitbutton(pressbutton){
	var form = document.adminForm;
	
	if(pressbutton == 'updateTable'){
		if(form.filter_table.value == ''){
			alert ('<?php echo JText::_('Please select a table to proceed'); ?>');
			form.filter_table.focus();
			return;
		}
		form.step.value = eval(form.step.value) + 1;
		if(confirm('<?php echo JText::_('Updating table may cause data lose. Do you want to continue?'); ?>')){
			form.task.value = pressbutton;
			form.submit();
		} else {
			return;
		}
	} else {
		form.task.value = pressbutton;
		form.submit();
	}
}
-->
</script>
<form name="adminForm" action="index.php" method="post">
<table width="100%">
	<tr>
	
		<td width="80%" valign="top">   
		    <div style="width:100%;">
				<table>
					<tr>
						<td align="left" width="100%">
							<?php echo JText::_( 'Filter' ); ?>:
							<input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
							<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
							<button onclick="document.getElementById('search').value='';this.form.getElementById('levellimit').value='10';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
						</td>
						<!--<td nowrap="nowrap">
						<?php
						echo JText::_( 'Table Filter' ).": &nbsp;";
						echo $this->lists['tables'];
						?>
					</td>-->
					</tr>
				</table>
		
				<table class="adminlist">
		        	<thead>
						<tr>
							<th width="5%">
								<?php echo JText::_( 'NUM' ); ?>
							</th>
							<th width="15%" nowrap="nowrap">
								<?php echo JText::_('Field Label'); ?>
							</th>
							<th width="20%">
								<?php echo JText::_('Table name'); ?>
							</th>
							<th width="25%" nowrap="nowrap">
								<?php echo JText::_('Field name'); ?>
							</th>
							<th width="25%" nowrap="nowrap">
								<?php echo JText::_('Field type'); ?>
							</th>							
							
							
							<th width="5%" nowrap="nowrap">
								<?php echo JText::_('Field Status'); ?>
							</th>
							
							<!--<th width="5%" class="title">
								<?php echo JText::_('Action'); ?>
							</th>-->
						</tr>
					</thead>
					<tbody>
		        	<?php
		        	$items = $this->items;
		        	$k = 0;
		        	$orderNo = 0;
		        	$FieldTypeList = JobBoardConstant::getFieldTypeList();
		        	$currentTable = '';
		        	for($i = 0, $n = count($items); $i < $n; $i++, $orderNo++){
		        		$item = $items[$i];
		        	
		        		?>
		        		<tr class="row<?php echo $k; ?>">
		            		<td align="center"><?php echo $this->pagination->getRowOffset($i); ?></td>
		            		
		            		<td>
								<?php echo $item->label; ?>
		            		</td>
		            		<td>
		            			<?php if ($item->old_table_name!=$item->table_name) {?>
		            				<del><?php echo $item->old_table_name; ?></del>  /  <font color="Red"><?php echo $item->table_name; ?></font>
		            			<?php } else { ?>
			            			<?php echo $item->table_name; ?>
			            		<?php } ?>
		            		</td>
		            		<td>
		            			<?php if ($item->old_field_name!=$item->field_name) {?>
		            				<?php echo "<del>".$item->old_field_name."</del>&nbsp;&nbsp;/&nbsp;&nbsp;<font color='Red'>".$item->field_name."</font>"; ?>
		            			<?php } else { ?>
		            				<?php echo $item->field_name; ?>
		            			<?php } ?>
		            		</td>
		            		<td>
		            			<?php if ($item->old_field_type!=$item->field_type) {?>
		            				<?php echo "<del>".$FieldTypeList[$item->old_field_type]."</del>&nbsp;&nbsp;/&nbsp;&nbsp;<font color='Red'>".$FieldTypeList[$item->field_type]."</font>"; ?>
		            			<?php } else { ?>
		            				<?php echo $FieldTypeList[$item->field_type]; ?>
		            			<?php } ?>
		            		</td>
		            		
		            		<td align="center"><?php echo JobBoardConstant::getFieldStateList($item->field_state); ?></td>
		            		<!--<td class="order" nowrap="nowrap">
								<a href="<?php JURI::base()?>index.php?option=<?php echo $this->lists['option']; ?>&view=jamanagefields&task=reverse&cid[]=<?php echo $item->id; ?>" onclick="return confirm('<?php echo htmlspecialchars(JText::_('Are you sure to reverse this field? If you choose ok, the system will restore field name and field type only, other parameters will be subject to latest change. Please go to field customization area to check again'))?>')"><?php echo JText::_('Reverse'); ?></a>
							</td>-->
		            	</tr>
		        	<?php
		        		$k = 1 - $k;
					}
		        	?>
		        	<tbody>
		        	<tfoot>
						<tr>
							<td colspan="10">
								<?php echo $this->pagination->getListFooter(); ?>
							</td>
						</tr>
					</tfoot>
				</table>
			</div>
		</td>
	</tr>
	</table>
	<input type="hidden" name="filter_table" value="<?php echo $item->table_name; ?>" />
	<input type="hidden" name="cid[]" value="<?php echo $item->id; ?>" />
	<input type="hidden" name="option" value="<?php echo $this->lists['option']; ?>" />
	<input type="hidden" name="view" value="jamanagefields" />
	<input type="hidden" name="task" value="updatetable" />
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="step" value="<?php echo $this->step; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>	
 </form>
